<?php /*
	
*/ ?>
<?php include("inc/head.inc.php") ?>
<body>
<table width="809" border="0" cellpadding="0" cellspacing="0"  align="center">
  
  <tr>
   <td class="headerclass"><?php include(INC."top.inc.php") ?></td>
  </tr>
  <tr>
    <td valign="top" class="maincontainer">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td width="235" valign="top"class="leftmenuback"><?php include(INC."left.inc.php")?></td>
				<td valign="top">
				<?php 
				if(isset($_REQUEST['intcatid']) && ($_REQUEST['intcatid'])!="")	{
					$catid = mysql_real_escape_string($_REQUEST['intcatid']);
					$namesql = "select varcategoryname from tblprodcategorydesc where intcatid=$catid";
					$result = $n02586916_db->select($namesql);
					$pagename = stripslashes($result[0]['varcategoryname']);
					$whereclauses = "AND tblproducts.intcategoryid=".$catid;
				} elseif (isset($_REQUEST['manufid']) && ($_REQUEST['manufid'])!="") {
					$manid = mysql_real_escape_string($_REQUEST['manufid']);
					$namesql = "select varname from tblmanufactures where intmanufactureid=$manid";
					$result = $n02586916_db->select($namesql);
					$pagename = stripslashes($result[0]['varname']);
					$whereclauses = "AND tblproducts.intmanufacture=".$manid;
				}
				?>
					<div class="pageheader"><?php echo $pagename;?></div>
					<div class="sortoptions">Sort By: <a href="category.php?sort=new&intcatid=<?php echo $catid;?>&manufid=<?php echo $manid;?>">Newest First</a> :: <a href="category.php?sort=htol&intcatid=<?php echo $catid;?>&manufid=<?php echo $manid;?>">Price Descending</a> :: <a href="category.php?sort=ltoh&intcatid=<?php echo $catid;?>&manufid=<?php echo $manid;?>">Price Ascending</a></div>
					<?php			
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='new')
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 $whereclauses ORDER BY tblproducts.dtaddeddate ASC";
			}
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='htol')
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 $whereclauses ORDER BY tblproducts.decprice DESC";
			}
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='ltoh')
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 $whereclauses ORDER BY tblproducts.decprice ASC";
			}
			else if(!isset($_REQUEST['sort']))
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 $whereclauses ORDER BY tblproducts.dtaddeddate ASC";
			}
			$products=$n02586916_db->select($sql);
			if(count($products)>0)
			{
				$colcount=0;
				for($h=0;$h<count($products);$h++)
				{
					$productname=stripslashes($products[$h]['varprodname']);
					$productdesc=stripslashes(myTruncate($products[$h]['txtdesc'], 100));
					if (file_exists("images/product/midium/".$products[$h]['intproddefaultimg'])) {
						$image = "images/product/midium/".$products[$h]['intproddefaultimg'];
					} else {
						$image = "images/product/noimage.jpg";
					}
					$productprice=$products[$h]['decprice'];
					$prodid=$products[$h]['intprodid'];
				
					if ($colcount==0) {
						echo "<div id=\"leftblock\"><div id=\"leftheader\">$productname</div><div id=\"leftcontent\"><div style=\"float:left;padding-right:3px;padding-bottom:3px;\"><img src=\"$image\" border=\"0\" width=\"80\" /></div>$productdesc<p class=\"pricetag\">&pound;$productprice</p><p class=\"byline\"><a href=\"proddetail.php?proid=$prodid\" class=\"aa\"><img src=\"images/buynow.jpg\" border=\"0\" /></a></p></div></div>";
						$colcount=1;
					} else {
						echo "<div id=\"rightblock\"><div id=\"rightheader\">$productname</div><div id=\"rightcontent\"><div style=\"float:left;padding-right:3px;padding-bottom:3px;\"><img src=\"$image\" border=\"0\" width=\"80\" /></div>$productdesc<p class=\"pricetag\">&pound;$productprice</p><p class=\"byline\"><a href=\"proddetail.php?proid=$prodid\" class=\"aa\"><img src=\"images/buynow.jpg\" border=\"0\" /></a></p></div></div>";
						$colcount=0;
					}
				}
			} else { 
				echo "<div align=\"center\">No products found at this time please try again later<br /><br /><a href=\"products.php\"><img src=\"images/continue.gif\" alt=\"Continue Shopping\" border=\"0\" /></a></div>";
			}
		?>	
				</td>
			</tr>
		</table>
    </td>
  </tr>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
</body>
</html>